package com.ssy.lingxi.platform.template.service.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.door.MemberShop;
import com.ssy.lingxi.platform.template.service.model.dto.common.CollectDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdListDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.MemberIdRoleIdShopIdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.web.SaveShopDTO;
import com.ssy.lingxi.platform.template.service.model.qo.CommonIdListPageQO;
import com.ssy.lingxi.platform.template.service.model.qo.MemberShopInGoodsListAdornQO;
import com.ssy.lingxi.platform.template.service.model.qo.MemberShopQO;
import com.ssy.lingxi.platform.template.service.model.vo.web.*;
import com.ssy.lingxi.platform.template.service.service.web.MemberShopWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu web - 会员店铺门户
 * @author fhj
 * @version 2.0.0
 * @date 2020/12/09
 */
@Api(tags = "web - 会员店铺门户")
@RestController
@RequestMapping("/template/web/memberShopWeb")
public class MemberShopWebController extends BaseController {

    @Resource
    private MemberShopWebService memberShopWebService;

    @ApiOperation(value = "保存当前登录会员的店铺门户")
    @PostMapping("/saveCurrMemberShop")
    public Wrapper<Void> saveCurrMemberShop(@RequestBody @Valid SaveShopDTO dto) {
        return memberShopWebService.saveCurrMemberShop(dto, getSysUser());
    }

    @ApiOperation(value = "获取当前登录会员的店铺门户")
    @GetMapping("/findCurrMemberShop")
    public Wrapper<MemberShop> findCurrMemberShop() {
        return memberShopWebService.findCurrMemberShop(getSysUser());
    }

    @ApiOperation(value = "店铺门户主页")
    @GetMapping("/memberShopMain")
    public Wrapper<MemberShopMainVO> memberShopMain(@Valid MemberIdRoleIdShopIdDTO dto) {
        return memberShopWebService.memberShopMain(dto, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "店铺门户列表")
    @GetMapping("/memberShopList")
    public Wrapper<PageData<MemberShopListVO>> memberShopList(@Valid MemberShopQO qo) {
        return memberShopWebService.memberShopList(qo, getHeadersShopId());
    }

    @ApiOperation(value = "店铺门户列表（装修）")
    @GetMapping("/memberShopListAdorn")
    public Wrapper<PageData<MemberShop>> memberShopListAdorn(@Valid PageVO dto, String memberName) {
        return memberShopWebService.memberShopListAdorn(dto, memberName);
    }

    @ApiOperation(value = "店铺门户包含商品列表（装修）")
    @PostMapping("/memberShopInGoodsListAdorn")
    public Wrapper<List<MemberShopInGoodsListAdornVO>> memberShopInGoodsListAdorn(@RequestBody @Valid MemberShopInGoodsListAdornQO qo) {
        return memberShopWebService.memberShopInGoodsListAdorn(qo);
    }

    @ApiOperation(value = "最新加入")
    @GetMapping("/newAddMemberShop")
    public Wrapper<List<MemberShop>> newAddMemberShop() {
        return memberShopWebService.newAddMemberShop();
    }

    @ApiOperation(value = "收藏/取消收藏")
    @PostMapping(value = "/collect")
    public Wrapper<Void> collect(@RequestBody @Validated CollectDTO dto) {
        return memberShopWebService.collect(dto, getSysUser());
    }

    @ApiOperation(value = "收藏列表")
    @GetMapping(value = "/collectList")
    public Wrapper<PageData<MemberShop>> collectList(PageVO dto) {
        return memberShopWebService.collectList(dto, getSysUser());
    }

    @ApiOperation(value = "根据店铺ID获取店铺")
    @GetMapping("/findById")
    public Wrapper<MemberShop> findById(@Valid IdDTO dto) {
        return memberShopWebService.findById(dto);
    }

    @ApiOperation(value = "根据店铺ID集合获取店铺")
    @GetMapping("/findByIdIn")
    public Wrapper<List<MemberShop>> findByIdIn(@Valid IdListDTO dto) {
        return memberShopWebService.findByIdIn(dto);
    }

    @ApiOperation(value = "根据不包含的店铺ID集合分页获取店铺")
    @GetMapping("/pageByIdNotIn")
    public Wrapper<PageData<MemberShop>> pageByIdNotIn(@Valid CommonIdListPageQO qo) {
        return memberShopWebService.pageByIdNotIn(qo);
    }

    @ApiOperation(value = "根据包含的店铺ID集合分页获取店铺")
    @GetMapping("/pageByIdIn")
    public Wrapper<PageData<MemberShop>> pageByIdIn(@Valid CommonIdListPageQO qo) {
        return memberShopWebService.pageByIdIn(qo);
    }

    @ApiOperation(value = "根据店铺ID集合分页获取店铺【最新商品】")
    @GetMapping("/pageProductByIdIn")
    public Wrapper<PageData<MemberShopProductVO>> pageProductByIdIn(@Valid CommonIdListPageQO qo) {
        return memberShopWebService.pageProductByIdIn(qo, getHeadersShopId());
    }

    @ApiOperation(value = "根据店铺ID集合获取店铺【主营分类】")
    @GetMapping("/findMainCategoryByIdIn")
    public Wrapper<List<MemberShopMainCategoryVO>> findMainCategoryByIdIn(@Valid IdListDTO dto) {
        return memberShopWebService.findMainCategoryByIdIn(dto);
    }
}